<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>推送app管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {
            //$("#name").focus();
            $("#inputForm").validate({
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
        // JS生成UUID
        //此函数生成16位UUID样式为af22-3fa8-4028-8dea-30a2
        function guid() {
            return 'xxxxxxxxxxxxyxxxyxxxxxxxyyyxxxxx'.replace(/[xy]/g, function (c) {
                var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
                return v.toString(16);
            });
        }
        function setUuid() {
            var uid = guid();
            $("#updateAppSecret").val(uid);
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/notify/notiApp/">app列表</a></li>
    <li class="active"><a href="${ctx}/notify/notiApp/form?id=${notiApp.id}">app<shiro:hasPermission
            name="notify:notiApp:edit">${not empty notiApp.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission
            name="notify:notiApp:edit">查看</shiro:lacksPermission></a></li>
</ul>
<br/>
<form:form id="inputForm" modelAttribute="notiApp" action="${ctx}/notify/notiApp/save" method="post"
           class="form-horizontal">
    <form:hidden id="formId" path="id"/>
    <sys:message content="${message}"/>
    <%--<div class="control-group">
        <label class="control-label">系统用户id：</label>
        <div class="controls">
            <form:input path="sysUserId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
        </div>
    </div>--%>
    <div class="control-group">
        <label class="control-label">app名称：</label>
        <div class="controls">
            <form:input path="appName" htmlEscape="false" maxlength="100" class="input-xlarge "/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">app图标：</label>
        <div class="controls">
            <form:hidden id="appIcon" path="appIcon" htmlEscape="false" maxlength="128" class="input-xlarge"/>
            <sys:ckfinder input="appIcon" type="files" uploadPath="/notify/notiApp" selectMultiple="true"/>
        </div>
    </div>
    <c:if test="${not empty notiApp.id}">
        <div class="control-group">
        <label class="control-label">AppKey：</label>
        <div class="controls">
            <form:input path="appKey" readonly="true" htmlEscape="false" maxlength="128" class="input-xlarge "/>
        </div>
    </c:if>
    </div>
    <c:if test="${not empty notiApp.id}">
        <div class="control-group">
            <label class="control-label">Master Secret：</label>
            <div class="controls">
                <form:input id="updateAppSecret" path="appSecret" value="" readonly="true" htmlEscape="false"
                            maxlength="128" class="input-xlarge "/>
                <input id="updateBtn" class="btn" type="button" value="重置Master Secret" onclick="setUuid()"/>
            </div>
        </div>
    </c:if>
    <%--
    <div class="control-group">
        <label class="control-label">新增用户数：</label>
        <div class="controls">
            <form:input path="addConsumerNumber" htmlEscape="false" maxlength="30" class="input-xlarge  digits"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">在线用户数：</label>
        <div class="controls">
            <form:input path="onlineConsumerNumber" htmlEscape="false" maxlength="30" class="input-xlarge  digits"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">总用户数：</label>
        <div class="controls">
            <form:input path="totalConsumerNumber" htmlEscape="false" maxlength="30" class="input-xlarge  digits"/>
        </div>
    </div>--%>
    <div class="control-group">
        <label class="control-label">创建时间：</label>
        <div class="controls">
            <input name="crateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
                   value="<fmt:formatDate value="${notiApp.crateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">最后更新时间：</label>
        <div class="controls">
            <input name="updateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
                   value="<fmt:formatDate value="${notiApp.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注：</label>
        <div class="controls">
            <form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
        </div>
    </div>
    <div class="form-actions">
        <shiro:hasPermission name="notify:notiApp:edit"><input id="btnSubmit" class="btn btn-primary" type="submit"
                                                               value="保 存"/>&nbsp;</shiro:hasPermission>
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</form:form>
</body>
</html>